from django.core.management.base import BaseCommand
from stock.models import PbcTradeType


def init_pbc_data():
    # PbcTradeType.objects.all().delete()
    # print("delete all pbc trade type data")

    PbcTradeType.objects.create(
        id=1,
        name='流动性总量处于合理充裕水平',
        description='银行体系流动性总量处于合理充裕水平',
        cid=1
    )
    PbcTradeType.objects.create(
        id=2,
        name='流动性总量处于较高水平',
        description='银行体系流动性总量处于较高水平',
        cid=2
    )
    PbcTradeType.objects.create(
        id=3,
        name='开展逆回购操作',
        description='为维护银行体系流动性合理充裕，人民银行以利率招标方式开展逆回购操作',
        cid=3
    )
    PbcTradeType.objects.create(
        id=4,
        name='MLF',
        description='中期借贷便利（MLF）',
        cid=4
    )
    PbcTradeType.objects.create(
        id=5,
        name='TMLF',
        description='定向中期借贷便利（TMLF）',
        cid=5
    )
    PbcTradeType.objects.create(
        id=6,
        name='存款准备金',
        description='降低存款准备金',
        cid=6
    )
    PbcTradeType.objects.create(
        id=7,
        name='央行票据',
        description='香港金融管理局债务工具中央结算系统（CMU）债券投标平台发行央行票据',
        cid=7
    )
    PbcTradeType.objects.create(
        id=8,
        name='其它',
        description='其它类型',
        cid=8
    )
    print("initial pbc trade type data")


class Command(BaseCommand):
    help = 'It is a initial database command, import initial data for modal'

    def handle(self, *args, **options):
        self.stdout.write(self.style.SUCCESS('begin initial modal data'))
        init_pbc_data()
        self.stdout.write(self.style.SUCCESS('end initial modal data'))
